home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 6.2 KB | 236 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Part.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: M.Boetcher
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Embed.hpp"
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef SELECT_H
- #include "Select.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- ODF -----
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- #ifndef FWMENUS_K
- #include "FWMenus.k"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_Commands_defined
- #include <CmdDefs.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- //========================================================================================
- // Runtime information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfembed
- #endif
-
- FW_DEFINE_AUTO(CEmbedPart)
-
- //========================================================================================
- // CLASS CEmbedPart
- //========================================================================================
-
- #define kMainPresentation "Apple:Presentation:EmbedPart"
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart constructor
- //----------------------------------------------------------------------------------------
-
- CEmbedPart::CEmbedPart(ODPart* odPart):
- FW_CEmbeddingPart(odPart, FW_gInstance, kPartInfoID),
- fPresentation(NULL),
- fEmbedContent(NULL),
- fFacetNumber(cOneFacet),
- fRotation(0)
- {
- // Do not call anything that can fail
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage)
- {
- FW_CEmbeddingPart::Initialize(ev, storageUnit, fromStorage);
-
- // Create the presentation and selection objects.
- // The selection object is actually owned by the presentation
- CEmbedSelection* selection = FW_NEW(CEmbedSelection, (ev, fEmbedContent));
- fPresentation = RegisterPresentation(ev, kMainPresentation, true, selection);
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart destructor
- //----------------------------------------------------------------------------------------
-
- CEmbedPart::~CEmbedPart()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::NewPartContent
- //----------------------------------------------------------------------------------------
-
- FW_CContent* CEmbedPart::NewPartContent(Environment* ev)
- {
- fEmbedContent = FW_NEW(CEmbedContent, (ev, this));
- return fEmbedContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CEmbedPart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage)
- {
- FW_UNUSED(presentation);
- FW_UNUSED(fromStorage);
-
- return FW_NEW(CEmbedFrame, (ev, odFrame, presentation, this, fEmbedContent));
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Handled CEmbedPart::DoAdjustMenus(Environment* ev,
- FW_CMenuBar* menuBar,
- FW_Boolean hasMenuFocus,
- FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
- if (hasMenuFocus)
- {
- FW_Boolean hasProxy = (fEmbedContent->GetProxy() != NULL);
- FW_Boolean oneFacet = (fFacetNumber == cOneFacet);
-
- menuBar->EnableAndCheckCommand(ev, cOneFacet, hasProxy, oneFacet);
- menuBar->EnableAndCheckCommand(ev, cFourFacets, hasProxy, !oneFacet);
- menuBar->EnableAndCheckCommand(ev, cRotateFacets, !oneFacet && (fEmbedContent->GetProxy() != NULL), false);
- }
-
- return FW_kNotHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Handled CEmbedPart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent)
- {
- FW_Handled menuHandled = FW_kHandled;
- ODCommandID id = theMenuEvent.GetCommandID(ev);
-
- switch (id)
- {
- case cOneFacet:
- case cFourFacets:
- ChangeEmbeddedFacets(ev, id);
- break;
-
- case cRotateFacets:
- CEmbedProxy* proxy = fEmbedContent->GetProxy();
- FW_ASSERT(proxy);
- fRotation++;
- proxy->RotateFacets(ev, fRotation);
- break;
-
- default:
- menuHandled = FW_kNotHandled;
- }
-
- return menuHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::DoAbout
- //----------------------------------------------------------------------------------------
-
- FW_Handled CEmbedPart::DoAbout(Environment* ev)
- {
- ::FW_About(ev, this, kAbout);
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CEmbedPart::ChangeEmbeddedFacets
- //----------------------------------------------------------------------------------------
-
- void CEmbedPart::ChangeEmbeddedFacets(Environment* ev, ODCommandID facetNumber)
- {
- if (fFacetNumber != facetNumber)
- {
- CEmbedProxy* proxy = fEmbedContent->GetProxy();
- FW_ASSERT(proxy);
-
- proxy->HideShow(ev, FALSE); // hide will remove all the facets
- fFacetNumber = facetNumber;
- proxy->HideShow(ev, TRUE); // Show will recreate the facets
-
- fPresentation->Invalidate(ev);
- }
- }
-
-